<?php

namespace app\admin\controller;

use app\facade\Basic;
use app\common\exception\ParameterException;
use think\exception\ValidateException;

class BaseController
{
    /**
     * 验证参数
     * @param array  $data     参数
     * @param string $validate 验证器
     */
    protected function validateData($data=[],$validate=''){

        try {
            validate($validate)->check($data);
        } catch (ValidateException $e) {
            exit(json_encode([
                'code' => 1,
                'message' => $e->getError()
            ]));
        }
    }
}
